home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************\
- * *
- * X_ref for YACC - LEX file *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~ *
- * Date: Tue Jul 1 03:36:21 BST 1986 *
- * *
- \*******************************************************/
-
- %{
-
- #define TRUE 1
- #define FALSE 0
-
- int recognised;
- int scope;
- char c, lastchar, thischar;
-
- %}
-
- /* abbreviations */
-
- digit [0-9]
- u_case [A-Z]
- l_case [a-z]
- id_char [A-Za-z0-9_\.]
- letter [A-Za-z\._]
- white [\t ]
-
-
- %%
-
- "/*" {
- ECHO;
- recognised = FALSE;
- c = nextchar();
- while (recognised == FALSE)
- {
- while (c != '*')
- c = nextchar();
- c = nextchar();
- if (c == '\/')
- recognised = TRUE;
- }
- }
- "%{" {
- ECHO;
- recognised = FALSE;
- c = nextchar();
- while (recognised == FALSE)
- {
- while (c != '\%')
- c = nextchar();
- c = nextchar();
- if (c == '\}')
- recognised = TRUE;
- }
- return(PERCURL);
- }
- "{" {
-
- /*
- * Although LEX can cope with the full definition,
- * ( "{"[^\}]*"}" ) this may overrun the lex buffer (200 chars).
- * Thus this routine.
- */
-
- ECHO;
- c = nextchar();
- scope = 1;
- while (scope > 0)
- {
- c = nextchar();
- switch (c)
- {
- case '*':
- if (lastchar == '/')
- do
- c = nextchar();
- while ((lastchar != '*') || (c != '/'));
- break;
- case '"':
- do
- c = nextchar();
- while ((lastchar == '\\') || (c != '"'));
- break;
- case '{':
- scope++;
- break;
- case '}':
- scope--;
- break;
- default:
- break;
- }
- }
- return(ACT);
- }
-
-
-
- {letter}{id_char}* {
- ECHO;
- return(IDENTIFIER);
- }
- "'"(\\.|[^'])+"'" {
- ECHO;
- return(CHARACTER);
- }
- {white}+ {
- ECHO;
- }
- {digit}+ {
- ECHO;
- return(NUMBER);
- }
- "%"{white}*"left" {
- ECHO;
- return(LEFT);
- }
- "%"{white}*"right" {
- ECHO;
- return(RIGHT);
- }
- "%"{white}*"nonassoc" {
- ECHO;
- return(NONASSOC);
- }
- "%"{white}*"token" {
- ECHO;
- return(TOKEN);
- }
- "%"{white}*"prec" {
- ECHO;
- return(PREC);
- }
- "%"{white}*"type" {
- ECHO;
- return(TYPE);
- }
- "%"{white}*"start" {
- ECHO;
- return(START);
- }
- "%"{white}*"union" {
- ECHO;
- return(UNION);
- }
- "%%" {
- ECHO;
- return(PER);
- }
- ":" {
- ECHO;
- return(COLON);
- }
- ";" {
- ECHO;
- return(SEMICOLON);
- }
- "," {
- ECHO;
- return(COMMA);
- }
- "|" {
- ECHO;
- return(OR);
- }
- "<" {
- ECHO;
- return(LESS);
- }
- ">" {
- ECHO;
- return(GREATER);
- }
- "\n" {
- ECHO;
- nline(++line);
- }
-
- %%
-
- yywrap()
- {
- /* wrap-up procedure */
- return(1);
- }
-
- nextchar()
- {
- char c;
-
- c = input();
- printf("%c",c);
- if (c == '\n')
- nline(++line);
- lastchar = thischar;
- thischar = c;
- return(c);
- }
-